"""
"""
import unittest as ut

import basicVdsTest as vdst
from confUtils import Validate
import vdsClient as vdsc
from storageConnectionTestUtils import eStorageType, disconnectFromStorage, connectToStorage, validateConnections, CONNECTIONS_OPTION_DEFAULT

class ConsecutiveConnect(vdst.BasicVDSTest):
    mycfg = property(lambda self: self.cfg[self.__class__.__name__])
    @classmethod
    def getConfigTemplate(cls):
        return { cls.__name__ : {
            "VdsUri1" : {"default" : "http://server:54321"},
            "Connections" : {"default" : CONNECTIONS_OPTION_DEFAULT, "validator" : validateConnections},
            }
        }

    def setUp(self):
        self.client = vdsc.VDSClient()
        self.client.setURI(self.mycfg["VdsUri1"])

    def test(self):
        try:
            connectToStorage(self.client, self.mycfg["Connections"])
            connectToStorage(self.client, self.mycfg["Connections"])
        except Exception, ex:
            self.fail(ex)

    def tearDown(self):
        disconnectFromStorage(self.client, self.mycfg["Connections"])

def suite():
    tests = {
        ConsecutiveConnect : ["test"]
    }

    resSuite = ut.TestSuite()
    for testcase, methods in tests.iteritems():
        resSuite.addTests(map(testcase, methods))

    return resSuite

validateConfig = lambda cfg : vdst.validateSuiteConfig(suite(), cfg)
